import 'package:flutter/material.dart';

class MyApp5 extends StatelessWidget {
  const MyApp5({super.key});

  @override
  Widget build(BuildContext context) {
    final screen = MediaQuery.of(context).size;
    return Scaffold(
      appBar: AppBar(
        title: Text(
          'Container组件',
          style: TextStyle(color: Colors.white, fontSize: 20),
        ),
        backgroundColor: Colors.red,
        centerTitle: true,
      ),
      body: Center(
        child: Container(
          width: screen.width,
          height: screen.height * 0.3,
          // color: Colors.green,如果设置了decoration属性,背景颜色必须放到decoration属性里面

          // margin: const EdgeInsets.all(20),
          // padding: const EdgeInsets.all(20),
          decoration: BoxDecoration(
            color: Colors.green,
            // borderRadius: BorderRadius.circular(10), //全部圆角
            borderRadius: BorderRadius.only(
              topLeft: Radius.circular(20),
            ), //部分圆角设置
            //设置边框.上边框的宽度是5px,颜色是红色
            border: Border(top: BorderSide(color: Colors.red, width: 5)),
          ),
          child: Container(
            //设置内容的对齐方式
            alignment: Alignment.center,
            color: Colors.yellow,
            padding: EdgeInsets.only(top: 20),
            margin: EdgeInsets.all(20),
            child: Text('我是一个Container', style: TextStyle(fontSize: 20)),
          ),
        ),
      ),
    );
  }
}
